<!DOCTYPE html>


<html lang="en">
  

    <head>
      <meta charset="utf-8" />
        
      <meta name="description" content="一个简单的记事网站" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title> 妮子和平子</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    </head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      
<section class="cover">
    
      
      <a class="forkMe" href="https://github.com/Shen-Yu/hexo-theme-ayer"
        target="_blank"><img width="149" height="149" src="/images/forkme.png"
          class="attachment-full size-full" alt="Fork me on GitHub" data-recalc-dims="1"></a>
    
  <div class="cover-frame">
    <div class="bg-box">
      <img src="/images/cover8.jpg" alt="image frame" />
    </div>
    <div class="cover-inner text-center text-white">
      <h1><a href="/">妮子和平子</a></h1>
      <div id="subtitle-box">
        
        <span id="subtitle"></span>
        
      </div>
      <div>
        
        <img
          src="true /images/ayer.svg，如果不要直接设置成false"
          class="cover-logo"
          alt="妮子和平子"
        />
        
      </div>
    </div>
  </div>
  <div class="cover-learn-more">
    <a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
  </div>
</section>



<script src="https://cdn.staticfile.org/typed.js/2.0.12/typed.min.js"></script>


<!-- Subtitle -->

  <script>
    try {
      var typed = new Typed("#subtitle", {
        strings: ['此生唯妮所爱', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
        startDelay: 0,
        typeSpeed: 200,
        loop: true,
        backSpeed: 100,
        showCursor: true
      });
    } catch (err) {
      console.log(err)
    }
  </script>
  
<div id="main">
  <section class="outer">
  
  <ul class="ads">
    
        <li>
            <a target="_blank" rel="noopener" href="https://curl.qcloud.com/kvO7hb43">
                <img src="https://pic.imgdb.cn/item/62174b452ab3f51d912a5ccc.jpg" width="300" alt="云服务器限时秒杀">
            </a>
        </li>
    
        <li>
            <a target="_blank" rel="noopener" href="https://www.vultr.com/?ref=8630075">
                <img src="https://pic.imgdb.cn/item/62174b452ab3f51d912a5cd7.png" width="300" alt="vultr优惠vps">
            </a>
        </li>
    
</ul>
  
  
  

<div class="notice" style="margin-top:50px">
    <i class="ri-heart-fill"></i>
    <div class="notice-content" id="broad"></div>
</div>
<script type="text/javascript">
    fetch('https://v1.hitokoto.cn')
        .then(response => response.json())
        .then(data => {
            document.getElementById("broad").innerHTML = data.hitokoto;
        })
        .catch(console.error)
</script>

<style>
    .notice {
        padding: 20px;
        border: 1px dashed #e6e6e6;
        color: #969696;
        position: relative;
        display: inline-block;
        width: 100%;
        background: #fbfbfb50;
        border-radius: 10px;
    }

    .notice i {
        float: left;
        color: #999;
        font-size: 16px;
        padding-right: 10px;
        vertical-align: middle;
        margin-top: -2px;
    }

    .notice-content {
        display: initial;
        vertical-align: middle;
    }
</style>
  
  <article class="articles">
    
    
    
    
    <article
  id="post-第一篇文章"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2025/03/18/%E7%AC%AC%E4%B8%80%E7%AF%87%E6%96%87%E7%AB%A0/"
    >第一篇文章</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2025/03/18/%E7%AC%AC%E4%B8%80%E7%AF%87%E6%96%87%E7%AB%A0/" class="article-date">
  <time datetime="2025-03-18T02:26:49.000Z" itemprop="datePublished">2025-03-18</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
   
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-hello-world"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2025/03/18/hello-world/"
    >Hello World</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2025/03/18/hello-world/" class="article-date">
  <time datetime="2025-03-18T02:21:04.815Z" itemprop="datePublished">2025-03-18</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p>Welcome to <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a target="_blank" rel="noopener" href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a target="_blank" rel="noopener" href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a target="_blank" rel="noopener" href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">&quot;My New Post&quot;</span></span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/writing.html">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/server.html">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/generating.html">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>

<p>More info: <a target="_blank" rel="noopener" href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-openstack liberty版本搭建"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
     
    <div class="article-meta">
      <a href="/2025/03/04/openstack%20liberty%E7%89%88%E6%9C%AC%E6%90%AD%E5%BB%BA/" class="article-date">
  <time datetime="2025-03-04T15:35:18.324Z" itemprop="datePublished">2025-03-04</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="Open-Stack-MITAKA版本搭建"><a href="#Open-Stack-MITAKA版本搭建" class="headerlink" title="Open Stack MITAKA版本搭建"></a>Open Stack MITAKA版本搭建</h1><h2 id="1、环境准备"><a href="#1、环境准备" class="headerlink" title="1、环境准备"></a>1、环境准备</h2><ul>
<li><p><strong>虚拟机准备</strong>：（安装推荐最小化安装网络准备）</p>
<p>​	1、控制节点：2处理器，2内存，10G存储</p>
<p>​	2、计算节点：2处理器，2内存，10G存储</p>
<p>​    3、更改主机名命令（两端都要配置）</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/hostname #改成controller、compute</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>网络配置</strong>：</p>
<p>​	1、永久关闭防火墙（双端都要配置）</p>
</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl disable firewalld</span><br></pre></td></tr></table></figure>

<p>​	      2、永久关闭SELinux（双端都要配置）</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/selinux/config #编辑selinux文件以永久关闭SELinux</span><br><span class="line">SELINUX=disabled #找到这一行修改成这样</span><br></pre></td></tr></table></figure>

<p>​		  3 、ens33网卡配置（双端）</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">TYPE=&quot;Ethernet&quot;</span><br><span class="line">PROXY_METHOD=&quot;none&quot;		</span><br><span class="line">BROWSER_ONLY=&quot;no&quot;</span><br><span class="line">BOOTPROTO=&quot;none&quot;		#这里改为none</span><br><span class="line">DEFROUTE=&quot;yes&quot;		</span><br><span class="line">IPV4_FAILURE_FATAL=&quot;no&quot;</span><br><span class="line">IPV6INIT=&quot;yes&quot;</span><br><span class="line">IPV6_AUTOCONF=&quot;yes&quot;</span><br><span class="line">IPV6_DEFROUTE=&quot;yes&quot;</span><br><span class="line">IPV6_FAILURE_FATAL=&quot;no&quot;</span><br><span class="line">IPV6_ADDR_GEN_MODE=&quot;stable-privacy&quot;</span><br><span class="line">NAME=&quot;ens33&quot;</span><br><span class="line">UUID=&quot;15857770-261b-4340-b866-5838618fe055&quot;</span><br><span class="line">DEVICE=&quot;ens33&quot;</span><br><span class="line">ONBOOT=&quot;yes&quot;</span><br><span class="line">IPADDR=192.168.230.110			#添加IP地址、网关、子网掩码、DNS</span><br><span class="line">GATEWAY=192.168.230.2</span><br><span class="line">NETMASK=255.255.255.0</span><br><span class="line">DNS1=192.168.230.2			#计算节点一样更改，计算节点ip添加为192.168.230.111 </span><br></pre></td></tr></table></figure>

<p>systemctl restart network  &#x2F;&#x2F;重启网卡，再尝试ping通外网。</p>
<p>4、配置hosts</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# echo &quot;192.168.230.110 controller&quot; &gt;&gt; /etc/hosts  #在控制节点配置hosts</span><br><span class="line">[root@controller ~]# echo &quot;192.168.230.111 compute&quot; &gt;&gt; /etc/hosts</span><br></pre></td></tr></table></figure>

<ul>
<li><h3 id="yum-源配置（双端，以下有两种方法可供选择，个人推荐第一种，第二种有待考究。）"><a href="#yum-源配置（双端，以下有两种方法可供选择，个人推荐第一种，第二种有待考究。）" class="headerlink" title="yum 源配置（双端，以下有两种方法可供选择，个人推荐第一种，第二种有待考究。）"></a><strong>yum 源配置</strong>（双端，以下有两种方法可供选择，个人推荐第一种，第二种有待考究。）</h3></li>
</ul>
<p><strong>第一种：</strong></p>
<p>1、 去阿里云官方yum源镜像网站下载或者去清华大学镜像网站下载等等，下载完成后用MobaXterm软件连接你的控制节点上传yum源压缩包到&#x2F;opt&#x2F;文件夹内</p>
<p>用 -tar -zxvf xxx 解压yum源压缩包</p>
<p>2、解压完成后 安装VM-Tools服务自启动</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">yum install -y open-vm-tools //安装tools工具</span><br><span class="line">systemctl enable vmtoolsd</span><br><span class="line">systemctl start vmtoolsd          </span><br></pre></td></tr></table></figure>

<p>3、编辑对应yum源[local]</p>
<p>vim &#x2F;etc&#x2F;yum.repos.d&#x2F;local.repo</p>
<p>添加以下内容：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">[local]</span><br><span class="line">name=local</span><br><span class="line">gpgcheck=0</span><br><span class="line">baseurl=file:///opt/repo</span><br><span class="line"></span><br><span class="line">[openstack]</span><br><span class="line">name=openstack</span><br><span class="line">gpgcheck=0</span><br><span class="line">baseurl=file:///opt/repo</span><br></pre></td></tr></table></figure>

<p>验证：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">yum clean all  //清除yum源</span><br><span class="line">yum repolist  //重新加载yum源</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\Desktop\实训（1）.jpg" alt="实训（1）"></p>
<p><strong>第二种</strong>：</p>
<p>1、去网络上搜索m版的镜像文件包然后用MobaXterm、Xshall或者winscp等等工具传输进主机两台虚拟机里</p>
<p>在目录下创建一个opt文件夹存放两个镜像文件mkdir &#x2F;opt&#x2F;</p>
<p><img src="C:\Users\23915\Desktop\openstack实训\3.png"></p>
<p>2、删除原有的在线镜像源，编辑新的镜像源文件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">rm -rf /etc/yum.repos.d/*</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">vi /etc/yum.repos.d/local.repo</span><br><span class="line">[centos]</span><br><span class="line">name=centos</span><br><span class="line">gpgcheck=0</span><br><span class="line">enabled=1</span><br><span class="line">baseurl=file:///opt/centos</span><br><span class="line">[Mitaka]</span><br><span class="line">name=mitaka</span><br><span class="line">gpgcheck=0</span><br><span class="line">enabled=1</span><br><span class="line">baseurl=file:///opt/mitaka/Openstack-Mitaka      #（计算节点一样，不建议使用ftp共同使用一个镜像源文件，后期下载报错频繁）</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">mount Mitaka.iso /opt/mitaka/</span><br><span class="line">mount CentOS-7-x86_64-DVD-1511.iso /opt/centos/  #挂载镜像源文件</span><br></pre></td></tr></table></figure>

<p>3、配置域名解析(双端)</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">#[root@controller ~]# vi /etc/hosts</span><br><span class="line"></span><br><span class="line">127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4</span><br><span class="line">::1         localhost localhost.localdomain localhost6 localhost6.localdomain6</span><br><span class="line">192.168.230.110 controller</span><br><span class="line">192.168.230.111 compute</span><br></pre></td></tr></table></figure>

<p>修改完成测试能否ping通</p>
<p><img src="C:\Users\23915\Desktop\openstack实训\4.png"></p>
<ul>
<li><h3 id="NTP服务安装"><a href="#NTP服务安装" class="headerlink" title="NTP服务安装"></a>NTP服务安装</h3></li>
</ul>
<p>控制节点：yum install -y chrony </p>
<p>vim &#x2F;etc&#x2F;chrony.conf</p>
<p>添加以下内容</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">#在26行下一行添加</span><br><span class="line">allow 192.168.230.0/24</span><br><span class="line"></span><br><span class="line">#然后重启NTP服务</span><br><span class="line">systemctl enable chronyd.service</span><br><span class="line">systemctl restart chronyd.service </span><br></pre></td></tr></table></figure>

<p>计算节点：yum install -y chrony</p>
<p>vim &#x2F;etc&#x2F;chrony.conf</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">#注释掉默认的NTP服务器</span><br><span class="line">#server 0.centos.pool.ntp.org iburst</span><br><span class="line">#server 1.centos.pool.ntp.org iburst</span><br><span class="line">#server 2.centos.pool.ntp.org iburst</span><br><span class="line">#server 3.centos.pool.ntp.org iburst</span><br><span class="line"></span><br><span class="line">#添加下面这行</span><br><span class="line">server controller iburst</span><br><span class="line"></span><br><span class="line">#然后重启NTP</span><br><span class="line">systemctl enable chronyd.service</span><br><span class="line">systemctl restart chronyd.service</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>验证：chronyc sources</p>
<p><img src="C:\Users\23915\Desktop\openstack实训\1.png" alt="+"></p>
<p><img src="C:\Users\23915\Desktop\openstack实训\2.png"></p>
<p>同步控制节点时间</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@compute ~]# ntpdate controller</span><br><span class="line">10 May 05:26:56 ntpdate[68187]: adjust time server 192.168.230.110 offset -0.016220 sec</span><br></pre></td></tr></table></figure>

<ul>
<li><h3 id="安装openstack安装包"><a href="#安装openstack安装包" class="headerlink" title="安装openstack安装包"></a>安装openstack安装包</h3><p>控制节点节点安装vsftpd服务并配置启动</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# yum -y install vsftpd                         </span><br><span class="line">[root@controller ~]# vi /etc/vsftpd/vsftpd.conf</span><br><span class="line"></span><br><span class="line">anon_root=/opt  #在最上面添加</span><br><span class="line"></span><br><span class="line">systemctl start vsftpd</span><br><span class="line">systemctl enable vsftpd</span><br></pre></td></tr></table></figure>

<p>安装Open stack包(两个节点都需要执行)</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# yum -y install openstack-utils openstack-selinux python-openstackclient</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230510202605502.png" alt="image-20230510202605502"></p>
<p>升级系统</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum upgrade</span><br></pre></td></tr></table></figure>
</li>
<li><h3 id="安装Mariadb数据库来存储信息"><a href="#安装Mariadb数据库来存储信息" class="headerlink" title="安装Mariadb数据库来存储信息"></a>安装Mariadb数据库来存储信息</h3></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">yum -y install mariadb mariadb-server python2-PyMySQL  #安装Mariadb服务</span><br><span class="line"></span><br><span class="line">[root@controller ~]# vi /etc/my.cnf  #编辑配置文件</span><br><span class="line">在[mysqld]下添加如下内容</span><br><span class="line">bind-address = 192.168.230.110</span><br><span class="line">default-storage-engine = innodb</span><br><span class="line">innodb_file_per_table</span><br><span class="line">max_connections = 4096</span><br><span class="line">collation-server = utf8_general_ci</span><br><span class="line">character-set-server = utf8</span><br><span class="line"></span><br><span class="line">#systemctl start mariadb  #启动数据库</span><br><span class="line">#systemctl enable mariadb</span><br></pre></td></tr></table></figure>

<ul>
<li><h3 id="运行mysql-secure-installation脚本-为root用户设置密码"><a href="#运行mysql-secure-installation脚本-为root用户设置密码" class="headerlink" title="运行mysql_secure_installation脚本,为root用户设置密码"></a>运行mysql_secure_installation脚本,为root用户设置密码</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">Enter current password for root (enter for none):   #这句话直接回车</span><br><span class="line"></span><br><span class="line">Set root password? [Y/n]       #选择Y，然后设置数据库密码  这里设置123</span><br><span class="line"></span><br><span class="line">Remove anonymous users? [Y/n]     #选择Y</span><br><span class="line"></span><br><span class="line">Disallow root login remotely? [Y/n]    #选择N</span><br><span class="line"></span><br><span class="line">Remove test database and access to it? [Y/n]    #选择Y</span><br><span class="line"></span><br><span class="line">Reload privilege tables now? [Y/n]    #选择Y</span><br></pre></td></tr></table></figure>

<p>验证：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# mysql -uroot -p000000</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230520214144024.png" alt="image-20230520214144024"></p>
</li>
<li><h3 id="安装memcached缓存服务"><a href="#安装memcached缓存服务" class="headerlink" title="安装memcached缓存服务"></a><strong>安装memcached缓存服务</strong></h3></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# yum -y install memcached python-memcached </span><br><span class="line"></span><br><span class="line">systemctl start memcached   #启动并设置开机启动</span><br><span class="line">systemctl enable memcached</span><br></pre></td></tr></table></figure>

<h1 id="2、keystone组件安装"><a href="#2、keystone组件安装" class="headerlink" title="2、keystone组件安装"></a>2、keystone组件安装</h1><ul>
<li><strong>进入mysql数据库</strong></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">create database keystone; #创建一个keystone数据库</span><br><span class="line">grant all privileges on keystone.* to &#x27;keystone&#x27;@&#x27;localhost&#x27; identified by &#x27;123&#x27;; #创建keystone用户并授予所有权限本地登陆并设置密码</span><br><span class="line">grant all privileges on keystone.* to &#x27;keystone&#x27;@&#x27;%&#x27; identified by &#x27;123&#x27;;  #创建keystone用户并授予所有权限任意地点登陆并设置密码</span><br></pre></td></tr></table></figure>

<ul>
<li><strong>安装相关软件包</strong></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# yum -y install openstack-keystone httpd mod_wsgi</span><br><span class="line">[root@controller ~]# cp /etc/keystone/keystone.conf&#123;,.bak&#125; #备份一份</span><br><span class="line">[root@controller ~]# egrep -v &#x27;^$|#&#x27; /etc/keystone/keystone.conf.bak &gt; /etc/keystone/keystone.conf  #清除不重要注释</span><br><span class="line">[root@controller ~]# vim /etc/keystone/keystone.conf     #编辑配置文件</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230520215118187.png" alt="image-20230520215118187"></p>
<ul>
<li><strong>同步数据库</strong></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">su -s /bin/sh -c &quot;keystone-manage db_sync&quot; keystone </span><br></pre></td></tr></table></figure>

<p>同步之后进入mysql验证</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -p123 </span><br><span class="line">use keystone;  #进入keystone数据库</span><br><span class="line">show tables;  #查看数据表同步是否成功</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230519214626152.png" alt="image-20230519214626152"></p>
<p>初始化数据库命令：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone</span><br></pre></td></tr></table></figure>

<ul>
<li><h3 id="配置HTTP服务"><a href="#配置HTTP服务" class="headerlink" title="配置HTTP服务"></a><strong>配置HTTP服务</strong></h3>编辑http配置文件，将servername写入提高响应速度</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">echo &#x27;ServerName controller&#x27; &gt;&gt; /etc/httpd/conf/httpd.conf   # 提高启动 http 速度</span><br></pre></td></tr></table></figure>

<p>创建并编辑文件     </p>
<p>vim &#x2F;etc&#x2F;httpd&#x2F;conf.d&#x2F;wsgi-keystone.conf</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">Listen 5000</span><br><span class="line">Listen 35357</span><br><span class="line"></span><br><span class="line">&lt;VirtualHost *:5000&gt;</span><br><span class="line"> WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%&#123;GROUP&#125;</span><br><span class="line"> WSGIProcessGroup keystone-public</span><br><span class="line"> WSGIScriptAlias / /usr/bin/keystone-wsgi-public</span><br><span class="line"> WSGIApplicationGroup %&#123;GLOBAL&#125;</span><br><span class="line"> WSGIPassAuthorization On</span><br><span class="line"> ErrorLogFormat &quot;%&#123;cu&#125;t %M&quot;</span><br><span class="line"> ErrorLog /var/log/httpd/keystone-error.log</span><br><span class="line"> CustomLog /var/log/httpd/keystone-access.log combined</span><br><span class="line"></span><br><span class="line"> &lt;Directory /usr/bin&gt;</span><br><span class="line">     Require all granted</span><br><span class="line"> &lt;/Directory&gt;</span><br><span class="line">&lt;/VirtualHost&gt;</span><br><span class="line"></span><br><span class="line">&lt;VirtualHost *:35357&gt;</span><br><span class="line"> WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%&#123;GROUP&#125;</span><br><span class="line"> WSGIProcessGroup keystone-admin</span><br><span class="line"> WSGIScriptAlias / /usr/bin/keystone-wsgi-admin</span><br><span class="line"> WSGIApplicationGroup %&#123;GLOBAL&#125;</span><br><span class="line"> WSGIPassAuthorization On</span><br><span class="line"> ErrorLogFormat &quot;%&#123;cu&#125;t %M&quot;</span><br><span class="line"> ErrorLog /var/log/httpd/keystone-error.log</span><br><span class="line"> CustomLog /var/log/httpd/keystone-access.log combined</span><br><span class="line"></span><br><span class="line"> &lt;Directory /usr/bin&gt;</span><br><span class="line">     Require all granted</span><br><span class="line"> &lt;/Directory&gt;</span><br><span class="line">&lt;/VirtualHost&gt;</span><br></pre></td></tr></table></figure>

<p>启动Apache HTTP 服务并配置开机自启</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">systemctl enable httpd.service </span><br><span class="line">systemctl start httpd.service    #开启成功即完成</span><br></pre></td></tr></table></figure>

<ul>
<li><h4 id="创建服务实体和API端点"><a href="#创建服务实体和API端点" class="headerlink" title="创建服务实体和API端点"></a><strong>创建服务实体和API端点</strong></h4><p>配置认证令牌：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">export OS_TOKEN=ADMIN_TOKEN                        # 配置认证令牌</span><br><span class="line">export OS_URL=http://controller:35357/v3           # 配置端点URL</span><br><span class="line">export OS_IDENTITY_API_VERSION=3                   # 配置认证 API 版本</span><br></pre></td></tr></table></figure>

<p>查看环境变量：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">env | grep OS</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230523105735893.png" alt="image-20230523105735893"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">创建服务实体和身份认证服务：</span><br><span class="line">openstack service create --name keystone --description &quot;OpenStack Identity&quot; identity</span><br><span class="line"></span><br><span class="line">创建认证服务的 API 端点：</span><br><span class="line">openstack endpoint create --region RegionOne identity public http://controller:5000/v3</span><br><span class="line">openstack endpoint create --region RegionOne identity internal http://controller:5000/v3</span><br><span class="line">openstack endpoint create --region RegionOne identity admin http://controller:35357/v3</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230523110028305.png" alt="image-20230523110028305"></p>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230523110004337.png" alt="image-20230523110004337"></p>
</li>
</ul>
<h3 id="如果创建端点的时候遇到以下这种情况"><a href="#如果创建端点的时候遇到以下这种情况" class="headerlink" title="如果创建端点的时候遇到以下这种情况"></a><u><code>如果创建端点的时候遇到以下这种情况</code></u></h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">openstack service list #查看创建的服务，如果服务重复可以删除其一或者都删除重新创建</span><br><span class="line">openstack service delete ID #你自己的那串代码</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230523110141326.png" alt="image-20230523110141326"></p>
<p>检验：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">openstack service list </span><br><span class="line">openstack endpoint list </span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230523110644315.png" alt="image-20230523110644315"></p>
<ul>
<li><h4 id="创建域，项目，用户以及角色"><a href="#创建域，项目，用户以及角色" class="headerlink" title="创建域，项目，用户以及角色"></a><strong>创建域，项目，用户以及角色</strong></h4></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">创建域 default     #这里的default只是名字，可自行修改，但是要与后面相对应</span><br><span class="line">[root@controller ~]# openstack domain create --description &quot;Default Domain&quot; default  </span><br><span class="line"></span><br><span class="line">创建admin项目：</span><br><span class="line">[root@controller ~]# openstack project create --domain default --description &quot;Admin Project&quot; admin</span><br><span class="line"></span><br><span class="line">创建admin用户：</span><br><span class="line">[root@controller ~]# openstack user create --domain default --password 123 admin  #此处六个零为admin用户的密码</span><br><span class="line"></span><br><span class="line">创建admin角色：</span><br><span class="line">[root@controller ~]# openstack role create admin</span><br><span class="line"></span><br><span class="line">添加`admin` 角色到 admin 项目和用户上：</span><br><span class="line">[root@controller ~]# openstack role add --project admin --user admin admin</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230523111337624.png" alt="image-20230523111337624"></p>
<ul>
<li><h4 id="创建service项目-以后添加的每个服务都会添加到service项目"><a href="#创建service项目-以后添加的每个服务都会添加到service项目" class="headerlink" title="创建service项目,以后添加的每个服务都会添加到service项目"></a><strong>创建service项目,以后添加的每个服务都会添加到service项目</strong></h4></li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# openstack project create --domain default --description &quot;Service Project&quot; service</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230523111621207.png" alt="image-20230523111621207"></p>
<ul>
<li><h4 id="创建demo项目，无特殊权限的项目，类似于普通用户组（验证是否能创建用户组，并且有访问权限）"><a href="#创建demo项目，无特殊权限的项目，类似于普通用户组（验证是否能创建用户组，并且有访问权限）" class="headerlink" title="创建demo项目，无特殊权限的项目，类似于普通用户组（验证是否能创建用户组，并且有访问权限）"></a>创建demo项目，无特殊权限的项目，类似于普通用户组（验证是否能创建用户组，并且有访问权限）</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# openstack project create --domain default --description &quot;Demo Project&quot; demo</span><br><span class="line"></span><br><span class="line">创建demo用户:</span><br><span class="line">[root@controller ~]# openstack user create --domain default --password 000000 demo</span><br><span class="line"></span><br><span class="line">创建user角色 </span><br><span class="line">[root@controller ~]# openstack role create user</span><br><span class="line"></span><br><span class="line">添加 user角色到 demo 项目和用户：</span><br><span class="line">[root@controller ~]# openstack role add --project demo --user demo user</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230523114214477.png" alt="image-20230523114214477"></p>
</li>
<li><h3 id="认证测试"><a href="#认证测试" class="headerlink" title="认证测试"></a>认证测试</h3><p>首先在&#x2F;root&#x2F;目录下创建脚本</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">vim admin-login /编辑脚本</span><br><span class="line"></span><br><span class="line">export OS_PROJECT_DOMAIN_NAME=default</span><br><span class="line">export OS_USER_DOMAIN_NAME=default</span><br><span class="line">export OS_PROJECT_NAME=admin</span><br><span class="line">export OS_USERNAME=admin</span><br><span class="line">export OS_PASSWORD=123</span><br><span class="line">export OS_AUTH_URL=http://controller:35357/v3</span><br><span class="line">export OS_IDENTITY_API_VERSION=3</span><br><span class="line">export OS_IMAGE_API_VERSION=2</span><br><span class="line"></span><br><span class="line">.admin-login #加载环境变量</span><br><span class="line"></span><br><span class="line">echo &#x27;source admin-login&#x27; &gt;&gt; /root/.bashrc # 开机自动挂载</span><br></pre></td></tr></table></figure>

<p>验证：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">logout   #退出登录再查看</span><br><span class="line">openstack token issue </span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230523115238848.png" alt="image-20230523115238848"></p>
</li>
</ul>
<h1 id="3、Glance组件安装"><a href="#3、Glance组件安装" class="headerlink" title="3、Glance组件安装"></a>3、Glance组件安装</h1><ul>
<li><h6 id="创建Glance数据库"><a href="#创建Glance数据库" class="headerlink" title="创建Glance数据库"></a>创建Glance数据库</h6><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -p123 #进入mysql数据库</span><br><span class="line"></span><br><span class="line">create database glance; #创建mysql数据库</span><br><span class="line">grant all privileges on glance.* to &#x27;glance&#x27;@&#x27;localhost&#x27; identified by &#x27;123&#x27;;</span><br><span class="line">grant all privileges on glance.* to &#x27;glance&#x27;@&#x27;%&#x27; identified by &#x27;123&#x27;;   #给予glance访问权限</span><br></pre></td></tr></table></figure></li>
</ul>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524090045939.png" alt="image-20230524090045939"></p>
<ul>
<li><h6 id="创建服务证数，创建用户-添加角色到项目上"><a href="#创建服务证数，创建用户-添加角色到项目上" class="headerlink" title="创建服务证数，创建用户,添加角色到项目上"></a>创建服务证数，创建用户,添加角色到项目上</h6><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">openstack user create --domain default --password 123 glance   #创建glance用户</span><br><span class="line">openstack role add --project service --user glance admin       #添加 admin 角色到 glance 用户和 service 项目上</span><br><span class="line">openstack service create --name glance --description &quot;OpenStack Image&quot; image     #创建glance服务实体</span><br></pre></td></tr></table></figure></li>
</ul>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524090124534.png" alt="image-20230524090124534"></p>
<ul>
<li><h6 id="创建镜像服务的-API-端点"><a href="#创建镜像服务的-API-端点" class="headerlink" title="创建镜像服务的 API 端点"></a>创建镜像服务的 API 端点</h6><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">openstack endpoint create --region RegionOne image public http://controller:9292</span><br><span class="line">openstack endpoint create --region RegionOne image internal http://controller:9292</span><br><span class="line">openstack endpoint create --region RegionOne image admin http://controller:9292</span><br></pre></td></tr></table></figure></li>
</ul>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524091303749.png" alt="image-20230524091303749"></p>
<ul>
<li><h6 id="安装glance软件包，并配置"><a href="#安装glance软件包，并配置" class="headerlink" title="安装glance软件包，并配置"></a>安装glance软件包，并配置</h6><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install openstack-glance  #安装glance组件</span><br></pre></td></tr></table></figure>

<p>编辑文件 &#x2F;etc&#x2F;glance&#x2F;glance-api.conf</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">cp /etc/glance/glance-api.conf&#123;,.bak&#125;               # 备份文件</span><br><span class="line">egrep -v &#x27;^$|#&#x27; /etc/glance/glance-api.conf.bak &gt; /etc/glance/glance-api.conf    #简化配置文件</span><br><span class="line"></span><br><span class="line">在[database]下添加</span><br><span class="line">connection = mysql+pymysql://glance:123@controller/glance</span><br><span class="line"></span><br><span class="line">在[keystone_authtoken]下添加</span><br><span class="line">auth_uri = http://controller:5000</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">memcached_servers = controller:11211</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">project_name = service</span><br><span class="line">username = glance</span><br><span class="line">password = 123 			#此处密码为之前创建的glance用户密码</span><br><span class="line"></span><br><span class="line">在[paste_deploy]下添加</span><br><span class="line">flavor = keystone</span><br><span class="line"></span><br><span class="line">在[glance_store]下添加，配置本地文件系统存储和镜像文件位置</span><br><span class="line">stores = file,http</span><br><span class="line">default_store = file</span><br><span class="line">filesystem_store_datadir = /var/lib/glance/images/</span><br></pre></td></tr></table></figure>

<p>编辑文件 &#x2F;etc&#x2F;glance&#x2F;glance-registry.conf</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">cp /etc/glance/glance-registry.conf&#123;,.bak&#125;               # 备份文件</span><br><span class="line">egrep -v &#x27;^$|#&#x27; /etc/glance/glance-registry.conf.bak &gt; /etc/glance/glance-registry.conf    #简化配置文件</span><br><span class="line"></span><br><span class="line">vim /etc/glance/glance-registry.conf</span><br><span class="line"></span><br><span class="line">在[database]下，添加</span><br><span class="line">connection = mysql+pymysql://glance:123@controller/glance</span><br><span class="line"></span><br><span class="line">在 [keystone_authtoken]下，配置认证服务访问：</span><br><span class="line">auth_uri = http://controller:5000</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">memcached_servers = controller:11211</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">project_name = service</span><br><span class="line">username = glance</span><br><span class="line">password = 123</span><br><span class="line"></span><br><span class="line">在[paste_deploy]下添加</span><br><span class="line">flavor = keystone</span><br></pre></td></tr></table></figure>

<p>同步数据库</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# su -s /bin/sh -c &quot;glance-manage db_sync&quot; glance  </span><br></pre></td></tr></table></figure></li>
</ul>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524095016429.png" alt="image-20230524095016429"></p>
<p>​       检验glance数据库是否有表项</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -p123;</span><br><span class="line">use glance;</span><br><span class="line">show tables;</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524095332441.png" alt="image-20230524095332441"> </p>
<ul>
<li>启动镜像并设置开机启动</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">systemctl start openstack-glance-api.service openstack-glance-registry.service  </span><br><span class="line">systemctl enable openstack-glance-api.service openstack-glance-registry.service   </span><br></pre></td></tr></table></figure>

<ul>
<li>检验</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img    #下载镜像源</span><br><span class="line"></span><br><span class="line">#使用qcow2磁盘格式，容器格式上传镜像到镜像服务并设置公共可见，这样所有的项目都可以访问它</span><br><span class="line">openstack image create &quot;cirros&quot; \</span><br><span class="line">  --file cirros-0.3.4-x86_64-disk.img \</span><br><span class="line">  --disk-format qcow2 --container-format bare \</span><br><span class="line">  --public</span><br><span class="line"></span><br><span class="line">openstack image list   #查看镜像</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524100750780.png" alt="image-20230524100750780"></p>
<h1 id="4、nova服务安装"><a href="#4、nova服务安装" class="headerlink" title="4、nova服务安装"></a><strong>4、nova服务安装</strong></h1><h4 id="以下命令在控制节点输入"><a href="#以下命令在控制节点输入" class="headerlink" title="以下命令在控制节点输入"></a><em><strong>以下命令在控制节点输入</strong></em></h4><ul>
<li>创建nova和nova-api数据库并授权</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -p123 </span><br><span class="line"></span><br><span class="line">create database nova;</span><br><span class="line">create database nova_api;</span><br><span class="line">grant all privileges on nova.* to &#x27;nova&#x27;@&#x27;localhost&#x27;  identified by &#x27;123&#x27;;</span><br><span class="line">grant all privileges on nova.* to &#x27;nova&#x27;@&#x27;%&#x27;  identified by &#x27;123&#x27;;</span><br><span class="line">grant all privileges on nova_api.* to &#x27;nova&#x27;@&#x27;localhost&#x27; identified by &#x27;123&#x27;;</span><br><span class="line">grant all privileges on nova_api.* to &#x27;nova&#x27;@&#x27;%&#x27; identified by &#x27;123&#x27;;</span><br></pre></td></tr></table></figure>

<ul>
<li>创建服务证书、用户和角色</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">openstack user create --domain default --password 123 nova  </span><br><span class="line"></span><br><span class="line">openstack service create --name nova --description &quot;OpenStack Compute&quot; compute   #创建 nova 服务实体</span><br><span class="line"></span><br><span class="line"> openstack role add --project service --user nova admin #给nova添加admin用户</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524112139089.png" alt="image-20230524112139089"></p>
<ul>
<li>创建compute服务api端点</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1/%\(tenant_id\)s</span><br><span class="line">openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1/%\(tenant_id\)s</span><br><span class="line">openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1/%\(tenant_id\)s</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524112719952.png" alt="image-20230524112719952"></p>
<ul>
<li>controller节点安装软件包</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">yum -y install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler</span><br><span class="line"></span><br><span class="line">注释：</span><br><span class="line">openstack-nova-api:           接受并响应所有计算服务的请求， 管理云主机的生命周期</span><br><span class="line">openstack-nova-conductor：    修改数据库中虚拟机的状态</span><br><span class="line">openstack-nova-console / openstack-nova-novncproxy : web版的VNC 直接操作云主机</span><br><span class="line">openstack-nova-scheduler：     调度器</span><br></pre></td></tr></table></figure>

<ul>
<li>编辑并修改相关配置文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line">cp /etc/nova/nova.conf&#123;,.bak&#125;    </span><br><span class="line">egrep -v &#x27;^$|#&#x27; /etc/nova/nova.conf.bak  &gt; /etc/nova/nova.conf    </span><br><span class="line"></span><br><span class="line">vim /etc/nova/nova.conf</span><br><span class="line"></span><br><span class="line">在[DEFAULT]下添加</span><br><span class="line">enabled_apis = osapi_compute,metadata</span><br><span class="line">rpc_backend = rabbit</span><br><span class="line">auth_strategy = keystone</span><br><span class="line">my_ip = 192.168.230.110           #ip为控制节点ip地址</span><br><span class="line">use_neutron = True</span><br><span class="line">firewall_driver = nova.virt.firewall.NoopFirewallDriver</span><br><span class="line"></span><br><span class="line">在[api_database]下添加</span><br><span class="line">connection = mysql+pymysql://nova:123@controller/nova_api</span><br><span class="line"></span><br><span class="line">在[database]下添加</span><br><span class="line">connection = mysql+pymysql://nova:123@controller/nova</span><br><span class="line"></span><br><span class="line">在[oslo_messaging_rabbit]下添加，配置 “RabbitMQ” 消息队列访问</span><br><span class="line">rabbit_host = controller</span><br><span class="line">rabbit_userid = openstack</span><br><span class="line">rabbit_password = 123</span><br><span class="line"></span><br><span class="line">在[keystone_authtoken]部分，配置认证服务访问：</span><br><span class="line">auth_uri = http://controller:5000</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">memcached_servers = controller:11211</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">project_name = service</span><br><span class="line">username = nova</span><br><span class="line">password = 123</span><br><span class="line"></span><br><span class="line">在[vnc]部分，配置VNC代理使用控制节点的管理接口IP地址 </span><br><span class="line">vncserver_listen = 192.168.100.10</span><br><span class="line">vncserver_proxyclient_address = 192.168.100.10</span><br><span class="line"></span><br><span class="line">在 [glance] 区域，配置镜像服务 API 的位置</span><br><span class="line">api_servers = http://controller:9292</span><br><span class="line"></span><br><span class="line">在 [oslo_concurrency] 部分，配置锁路径：</span><br><span class="line">lock_path = /var/lib/nova/tmp</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ul>
<li>同步数据库</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">su -s /bin/sh -c &quot;nova-manage api_db sync&quot; nova</span><br><span class="line">su -s /bin/sh -c &quot;nova-manage db sync&quot; nova</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524114130863.png" alt="image-20230524114130863"></p>
<ul>
<li>启动服务</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service</span><br><span class="line"></span><br><span class="line">systemctl start openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service</span><br></pre></td></tr></table></figure>

<ul>
<li>检验</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">查看报错日志</span><br><span class="line">tail -f /var/log/nova/nova-* | grep ERRO     # 没有输出即为成功</span><br><span class="line"></span><br><span class="line">检测</span><br><span class="line">openstack compute service list </span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230524114736227.png" alt="image-20230524114736227"></p>
<h4 id="以下命令在计算节点输入"><a href="#以下命令在计算节点输入" class="headerlink" title="以下命令在计算节点输入"></a><em><strong>以下命令在计算节点输入</strong></em></h4><ul>
<li>安装nova组件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br></pre></td><td class="code"><pre><span class="line">yum -y install openstack-nova-compute          #安装nova相关软件包</span><br><span class="line"></span><br><span class="line">scp root@controller:/etc/nova/nova.conf /etc/nova        #运用scp命令远程接收文件</span><br><span class="line"></span><br><span class="line">vim /etc/nova/nova.conf             #把文件里的所有ip地址改成计算节点ip</span><br><span class="line"></span><br><span class="line">[DEFAULT]</span><br><span class="line">rpc_backend = rabbit</span><br><span class="line">auth_strategy = keystone</span><br><span class="line">my_ip = 192.168.230.111</span><br><span class="line">use_neutron = True</span><br><span class="line">firewall_driver = nova.virt.firewall.NoopFirewallDriver</span><br><span class="line">[api_database]</span><br><span class="line">connection = mysql+pymysql://nova:123@controller/nova_api</span><br><span class="line">[barbican]</span><br><span class="line">[cache]</span><br><span class="line">[cells]</span><br><span class="line">[cinder]</span><br><span class="line">[conductor]</span><br><span class="line">[cors]</span><br><span class="line">[cors.subdomain]</span><br><span class="line">[database]</span><br><span class="line">connection = mysql+pymysql://nova:123@controller/nova</span><br><span class="line">[ephemeral_storage_encryption]</span><br><span class="line">[glance]</span><br><span class="line">api_servers = http://controller:9292</span><br><span class="line">[guestfs]</span><br><span class="line">[hyperv]</span><br><span class="line">[image_file_url]</span><br><span class="line">[ironic]</span><br><span class="line">[keymgr]</span><br><span class="line">[keystone_authtoken]</span><br><span class="line">auth_uri = http://controller:5000</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">memcached_servers = controller:11211</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">project_name = service</span><br><span class="line">username = nova</span><br><span class="line">password = 123</span><br><span class="line">[libvirt]</span><br><span class="line">[matchmaker_redis]</span><br><span class="line">[metrics]</span><br><span class="line">[neutron]</span><br><span class="line">[osapi_v21]</span><br><span class="line">[oslo_concurrency]</span><br><span class="line">lock_path = /var/lib/nova/tmp</span><br><span class="line">[oslo_messaging_amqp]</span><br><span class="line">[oslo_messaging_notifications]</span><br><span class="line">[oslo_messaging_rabbit]</span><br><span class="line">rabbit_host = controller</span><br><span class="line">rabbit_userid = openstack</span><br><span class="line">rabbit_password = 123</span><br><span class="line">[oslo_middleware]</span><br><span class="line">[oslo_policy]</span><br><span class="line">[rdp]</span><br><span class="line">[serial_console]</span><br><span class="line">[spice]</span><br><span class="line">[ssl]</span><br><span class="line">[trusted_computing]</span><br><span class="line">[upgrade_levels]</span><br><span class="line">[vmware]</span><br><span class="line">[vnc]</span><br><span class="line">enabled = True</span><br><span class="line">vncserver_listen = 0.0.0.0</span><br><span class="line">vncserver_proxyclient_address = 192.168.230.111</span><br><span class="line">novncproxy_base_url = http://controller:6080/vnc_auto.html</span><br><span class="line">[workarounds]</span><br><span class="line">[xenserver]</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230527202512365.png" alt="image-20230527202512365"></p>
<ul>
<li>确定您的计算节点是否开启虚拟化； 如果输出结果为 1或非零数 就不需要修改， 如果为零就需要打开虚拟机设置页面进行设置</li>
</ul>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230527203002424.png" alt="image-20230527203002424"></p>
<ul>
<li>打开虚拟机设置里勾选以下两个选项，如果出现选项灰色勾选不了，关闭虚拟机即可</li>
</ul>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230527202753991.png" alt="image-20230527202753991"></p>
<ul>
<li>编辑&#x2F;etc&#x2F;nova&#x2F;nova.conf 文件的 [libvirt]</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/nova/nova.conf</span><br><span class="line"></span><br><span class="line">在[libvirtd]下添加</span><br><span class="line">virt_type = qemu</span><br><span class="line">cpu_mode = none</span><br></pre></td></tr></table></figure>

<ul>
<li>计算节点启动nova服务并设置开机启动</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@compute ~]# systemctl start libvirtd.service openstack-nova-compute.service</span><br><span class="line">[root@compute ~]# systemctl enable libvirtd.service openstack-nova-compute.service</span><br></pre></td></tr></table></figure>

<ul>
<li>进入控制节点查看四个服务是否开启成功</li>
</ul>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230527204241831.png" alt="image-20230527204241831"></p>
<h1 id="5、neutron服务安装"><a href="#5、neutron服务安装" class="headerlink" title="5、neutron服务安装"></a><strong>5、neutron服务安装</strong></h1><h4 id="以下均在控制节点执行"><a href="#以下均在控制节点执行" class="headerlink" title="以下均在控制节点执行"></a><em><strong>以下均在控制节点执行</strong></em></h4><ul>
<li>登录mysql数据库</li>
</ul>
<p>创建mysql数据库neutron，并对neutron授权</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">CREATE DATABASE neutron;</span><br><span class="line"></span><br><span class="line">GRANT ALL PRIVILEGES ON neutron.* TO &#x27;neutron&#x27;@&#x27;localhost&#x27; IDENTIFIED BY &#x27;123&#x27;;</span><br><span class="line">GRANT ALL PRIVILEGES ON neutron.* TO &#x27;neutron&#x27;@&#x27;%&#x27; IDENTIFIED BY &#x27;123&#x27;;</span><br></pre></td></tr></table></figure>

<ul>
<li>创建neutron用户、服务证书以及服务实体</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@controller~]#  user create --domain default --password 123 neutron</span><br><span class="line">[root@controller~]# openstack role add --project service --user neutron admin</span><br><span class="line">[root@controller~]# openstack service create --name neutron --description &quot;OpenStack Networking&quot; network</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230527205335115.png" alt="image-20230527205335115"></p>
<ul>
<li>创建neutron服务api端点</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@controller~]# openstack endpoint create --region RegionOne network public http://controller:9696</span><br><span class="line">[root@controller~]# openstack endpoint create --region RegionOne network internal http://controller:9696</span><br><span class="line">[root@controller~]# openstack endpoint create --region RegionOne network admin http://controller:9696</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230527205550264.png" alt="image-20230527205550264"></p>
<ul>
<li>controller节点安装并配置网络服务组件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@controller~]# yum -y install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables</span><br></pre></td></tr></table></figure>

<p>以下编辑配置文件可以用openstack-config –set命令直接写入进配置文件中也可以像我一样用”&#x2F;“命令一个个找</p>
<ul>
<li>编辑 &#x2F;etc&#x2F;neutron&#x2F;neutron.conf文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">在 [database] 部分，配置数据库访问：</span><br><span class="line">connection = mysql+pymysql://neutron:123@controller/neutron</span><br><span class="line"></span><br><span class="line">在``[DEFAULT]``部分，添加如下内容</span><br><span class="line">core_plugin = ml2</span><br><span class="line">service_plugins = router</span><br><span class="line">allow_overlapping_ips = True</span><br><span class="line">rpc_backend = rabbit</span><br><span class="line">auth_strategy = keystone</span><br><span class="line">notify_nova_on_port_status_changes = True</span><br><span class="line">notify_nova_on_port_data_changes = True</span><br><span class="line"></span><br><span class="line">在[oslo_messaging_rabbit]部分，配置 “RabbitMQ” 消息队列的连接：</span><br><span class="line">rabbit_host = controller</span><br><span class="line">rabbit_userid = openstack</span><br><span class="line">rabbit_password = 123</span><br><span class="line"></span><br><span class="line">在[keystone_authtoken]部分，配置认证服务访问</span><br><span class="line">auth_uri = http://controller:5000</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">memcached_servers = controller:11211</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">project_name = service</span><br><span class="line">username = neutron</span><br><span class="line">password = 123</span><br><span class="line"></span><br><span class="line">在[nova]部分，配置网络服务来通知计算节点的网络拓扑变化：</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">region_name = RegionOne</span><br><span class="line">project_name = service</span><br><span class="line">username = nova</span><br><span class="line">password = 123</span><br><span class="line"></span><br><span class="line">在 [oslo_concurrency] 部分，配置锁路径：</span><br><span class="line">lock_path = /var/lib/neutron/tmp</span><br></pre></td></tr></table></figure>

<ul>
<li>编辑&#x2F;etc&#x2F;neutron&#x2F;plugins&#x2F;ml2&#x2F;ml2_conf.ini文件，配置启用flat，VLAN，GRE,LOCAL以及VXLAN网络</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">在[ml2]下添加</span><br><span class="line">type_drivers = flat,vlan,vxlan,gre,local</span><br><span class="line">tenant_network_types = vxlan</span><br><span class="line">mechanism_drivers = linuxbridge,l2population</span><br><span class="line">extension_drivers = port_security</span><br><span class="line"></span><br><span class="line">在 [ml2_type_flat] 部分，配置公共虚拟网络为flat网络</span><br><span class="line">flat_networks = provider</span><br><span class="line"></span><br><span class="line">在 [ml2_type_vxlan] 部分，为私有网络配置VXLAN网络识别的网络范围：</span><br><span class="line">vni_ranges = 1:1000</span><br><span class="line"></span><br><span class="line">在 [securitygroup] 部分，启用 ipset 增加安全组规则的高效性：</span><br><span class="line">enable_ipset = True</span><br></pre></td></tr></table></figure>

<ul>
<li>配置linuxbridge代理，编辑文件&#x2F;etc&#x2F;neutron&#x2F;plugins&#x2F;ml2&#x2F;linuxbridge_agent.ini</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">在 [linux_bridge] 部分，将公共虚拟网络和公共物理网络接口对应起来：</span><br><span class="line">physical_interface_mappings = provider:ens33  #注意，此处的ens33为基础环境配置中的230的网段 也就是  192.168.230.0/24</span><br><span class="line"></span><br><span class="line">在 [vxlan] 部分，启用VXLAN覆盖网络，配置覆盖网络的物理网络接口的IP地址，启用layer－2 population：</span><br><span class="line">enable_vxlan = True</span><br><span class="line">local_ip = 192.168.230.110   #这里的IP地址是controller的ip地址</span><br><span class="line">l2_population = True</span><br><span class="line"></span><br><span class="line">在  [securitygroup] 部分，启用安全组并配置 Linuxbridge iptables firewall driver:</span><br><span class="line">enable_security_group = True</span><br><span class="line">firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver</span><br></pre></td></tr></table></figure>

<ul>
<li>配置layer－3代理，编辑文件&#x2F;etc&#x2F;neutron&#x2F;l3_agent.ini</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">在[DEFAULT]下添加</span><br><span class="line">interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver</span><br><span class="line">external_network_bridge =</span><br></pre></td></tr></table></figure>

<ul>
<li>配置DHCP代理编辑&#x2F;etc&#x2F;neutron&#x2F;dhcp_agent.ini文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">在[DEFAULT]下添加</span><br><span class="line">interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver</span><br><span class="line">dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq</span><br><span class="line">enable_isolated_metadata = True</span><br></pre></td></tr></table></figure>

<ul>
<li>编辑&#x2F;etc&#x2F;neutron&#x2F;metadata_agent.ini文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">在``[DEFAULT]`` 部分，配置元数据主机以及共享密码：</span><br><span class="line">nova_metadata_ip = controller</span><br><span class="line">metadata_proxy_shared_secret = 123</span><br></pre></td></tr></table></figure>

<ul>
<li>编辑&#x2F;etc&#x2F;nova&#x2F;nova.conf文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">在``[neutron]``部分，配置访问参数，启用元数据代理并设置密码：</span><br><span class="line">url = http://controller:9696</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">region_name = RegionOne</span><br><span class="line">project_name = service</span><br><span class="line">username = neutron</span><br><span class="line">password = 123</span><br><span class="line">service_metadata_proxy = True</span><br><span class="line">metadata_proxy_shared_secret = 123</span><br></pre></td></tr></table></figure>

<ul>
<li>网络服务初始化生成超链接</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini</span><br></pre></td></tr></table></figure>

<ul>
<li>同步数据库</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">su -s /bin/sh -c &quot;neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head&quot; neutron</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230529095835218.png" alt="image-20230529095835218"></p>
<ul>
<li>Controller节点重启计算Nova_API服务</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart openstack-nova-api.service</span><br></pre></td></tr></table></figure>

<ul>
<li>启动网络服务并设置开机启动</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">systemctl start neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service</span><br><span class="line"></span><br><span class="line">systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-l3-agent.service</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230529101120999.png" alt="image-20230529101120999"></p>
<h4 id="以下均在计算节点执行"><a href="#以下均在计算节点执行" class="headerlink" title="以下均在计算节点执行"></a><em><strong>以下均在计算节点执行</strong></em></h4><ul>
<li>计算节点安装并配置neutron服务</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install openstack-neutron-linuxbridge ebtables ipset</span><br></pre></td></tr></table></figure>

<ul>
<li>编辑&#x2F;etc&#x2F;neutron&#x2F;neutron.conf 文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">在 “[DEFAULT]” 下添加</span><br><span class="line">rpc_backend = rabbit</span><br><span class="line">auth_strategy = keystone</span><br><span class="line"></span><br><span class="line">在[oslo_messaging_rabbit]下添加</span><br><span class="line">rabbit_host = controller</span><br><span class="line">rabbit_userid = openstack</span><br><span class="line">rabbit_password = 123</span><br><span class="line"></span><br><span class="line">在[keystone_authtoken]下添加</span><br><span class="line">auth_uri = http://controller:5000</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">memcached_servers = controller:11211</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">project_name = service</span><br><span class="line">username = neutron</span><br><span class="line">password = 123</span><br><span class="line"></span><br><span class="line">在 [oslo_concurrency] 部分，配置锁路径：</span><br><span class="line">lock_path = /var/lib/neutron/tmp</span><br></pre></td></tr></table></figure>

<ul>
<li>编辑&#x2F;etc&#x2F;neutron&#x2F;plugins&#x2F;ml2&#x2F;linuxbridge_agent.ini文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">在 [linux_bridge] 部分,将公共虚拟网络和公共物理网络接口对应起来</span><br><span class="line">physical_interface_mappings = provider:ens33      #ens33为你的网卡名</span><br><span class="line"></span><br><span class="line">在 [vxlan] 部分，启用VXLAN覆盖网络，配置覆盖网络的物理网络接口的IP地址，启用layer－2 population：</span><br><span class="line">enable_vxlan = True</span><br><span class="line">local_ip = 192.168.230.111 #此处为计算节点ip </span><br><span class="line">l2_population = True</span><br><span class="line"></span><br><span class="line">在  [securitygroup] 部分，启用安全组并配置 Linuxbridge iptables firewall driver:</span><br><span class="line">enable_security_group = True</span><br><span class="line">firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver</span><br></pre></td></tr></table></figure>

<ul>
<li>编辑&#x2F;etc&#x2F;nova&#x2F;nova.conf文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">在[neutron]部分添加</span><br><span class="line"></span><br><span class="line">url = http://controller:9696</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">region_name = RegionOne</span><br><span class="line">project_name = service</span><br><span class="line">username = neutron</span><br><span class="line">password = 123</span><br></pre></td></tr></table></figure>

<ul>
<li>compute节点重启服务并设置开机自启</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart openstack-nova-compute.service neutron-linuxbridge-agent.service</span><br><span class="line">systemctl enable neutron-linuxbridge-agent.service</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230529103126927.png" alt="image-20230529103126927"></p>
<ul>
<li>验证（去控制节点）：</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">neutron ext-list</span><br><span class="line">neutron agent-list</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230529111629714.png" alt="image-20230529111629714"></p>
<h1 id="5、dashboard服务安装"><a href="#5、dashboard服务安装" class="headerlink" title="5、dashboard服务安装"></a><strong>5、dashboard服务安装</strong></h1><h4 id="控制节点操作"><a href="#控制节点操作" class="headerlink" title="控制节点操作"></a><em><strong>控制节点操作</strong></em></h4><ul>
<li>安装并配置dashboard</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line">yum -y install openstack-dashboard</span><br><span class="line"></span><br><span class="line">编辑文件 /etc/openstack-dashboard/local_settings </span><br><span class="line">vim /etc/openstack-dashboard/local_settings</span><br><span class="line"></span><br><span class="line">请找到并修改如下内容</span><br><span class="line"></span><br><span class="line">OPENSTACK_HOST = &quot;controller&quot;</span><br><span class="line">OPENSTACK_KEYSTONE_URL = &quot;http://%s:5000/v3&quot; % OPENSTACK_HOST</span><br><span class="line">OPENSTACK_KEYSTONE_DEFAULT_ROLE = &quot;user&quot;</span><br><span class="line"></span><br><span class="line">ALLOWED_HOSTS = [&#x27;*&#x27;, ]</span><br><span class="line"></span><br><span class="line">OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True</span><br><span class="line">OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = &quot;default&quot;</span><br><span class="line"></span><br><span class="line">OPENSTACK_API_VERSIONS = &#123;</span><br><span class="line">    &quot;identity&quot;: 3,</span><br><span class="line">    &quot;compute&quot;: 2,</span><br><span class="line">    &quot;volume&quot;: 2,</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">CACHES = &#123;</span><br><span class="line">    &#x27;default&#x27;: &#123;</span><br><span class="line">         &#x27;BACKEND&#x27;: &#x27;django.core.cache.backends.memcached.MemcachedCache&#x27;,</span><br><span class="line">         &#x27;LOCATION&#x27;: &#x27;controller:11211&#x27;,</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">添加</span><br><span class="line">SESSION_ENGINE = &#x27;django.contrib.sessions.backends.cache&#x27;</span><br></pre></td></tr></table></figure>

<ul>
<li>修改完配置文件后重启httpd服务然后去浏览器打开 <a target="_blank" rel="noopener" href="http://192.168.230.110/dashboard">http://192.168.230.110/dashboard</a>  （ip是你安装dashboard节点的ip）</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart httpd.service memcached.service</span><br></pre></td></tr></table></figure>

<p>如果显示错误500的代码例如：</p>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230530105237423.png" alt="image-20230530105237423"></p>
<ul>
<li>vim &#x2F;etc&#x2F;httpd&#x2F;conf.d&#x2F;openstack-dashboard.conf 进入到该配置文件中，添加一条命令即可</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">WSGIApplicationGroup %&#123;GLOBAL&#125;</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230530105516381.png" alt="image-20230530105516381"></p>
<p>然后退出并保存，接着重启httpd服务再次进入opesntack web页面。</p>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230530103912090.png" alt="image-20230530103912090"></p>
<h1 id="6、cinder服务安装"><a href="#6、cinder服务安装" class="headerlink" title="6、cinder服务安装"></a><strong>6、cinder服务安装</strong></h1><ul>
<li>登录MySQL数据库创建cinder数据库并授权</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -p123</span><br><span class="line"></span><br><span class="line">create database cinder;</span><br><span class="line">grant all privileges on cinder.* to &#x27;cinder&#x27;@&#x27;localhost&#x27; identified by &#x27;123&#x27;;</span><br><span class="line">grant all privileges on cinder.* to &#x27;cinder&#x27;@&#x27;%&#x27; identified by &#x27;123&#x27;;</span><br></pre></td></tr></table></figure>

<ul>
<li>创建服务证书</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">openstack user create --domain default --password 123 cinder</span><br><span class="line">openstack role add --project service --user cinder admin</span><br><span class="line"></span><br><span class="line">openstack service create --name cinder --description &quot;OpenStack Block Storage&quot; volume</span><br><span class="line">openstack service create --name cinderv2 --description &quot;OpenStack Block Storage&quot; volumev2   #创建服务实体</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603185537639.png" alt="image-20230603185537639"></p>
<ul>
<li>创建块存储设备API接口</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">#openstack endpoint create --region RegionOne volume public http://controller:8776/v1/%\(tenant_id\)s</span><br><span class="line">#openstack endpoint create --region RegionOne volume internal http://controller:8776/v1/%\(tenant_id\)s</span><br><span class="line">#openstack endpoint create --region RegionOne volume admin http://controller:8776/v1/%\(tenant_id\)s</span><br><span class="line"></span><br><span class="line">#openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(tenant_id\)s</span><br><span class="line">#openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(tenant_id\)s</span><br><span class="line">#openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(tenant_id\)s</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603185724726.png" alt="image-20230603185724726"></p>
<ul>
<li>Controller节点安装块存储组件并配置文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">[root@controller ~]# yum -y install openstack-cinder </span><br><span class="line"></span><br><span class="line">cp /etc/cinder/cinder.conf&#123;,.bak&#125;    </span><br><span class="line">egrep -v &#x27;^$|#&#x27; /etc/cinder/cinder.conf.bak  &gt; /etc/cinder/cinder.conf</span><br><span class="line"></span><br><span class="line">vim /etc/cinder/cinder.conf</span><br><span class="line">在 “[DEFAULT]” 下添加</span><br><span class="line">rpc_backend = rabbit</span><br><span class="line">auth_strategy = keystone</span><br><span class="line">my_ip = 192.168.230.110</span><br><span class="line"></span><br><span class="line">在[database]下添加</span><br><span class="line">connection = mysql+pymysql://cinder:123@controller/cinder</span><br><span class="line"></span><br><span class="line">在[oslo_messaging_rabbit]部分，配置 “RabbitMQ” 消息队列访问：</span><br><span class="line">rabbit_host = controller</span><br><span class="line">rabbit_userid = openstack</span><br><span class="line">rabbit_password = 123</span><br><span class="line"></span><br><span class="line">在[keystone_authtoken]部分，配置认证服务访问：</span><br><span class="line">auth_uri = http://controller:5000</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">memcached_servers = controller:11211</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">project_name = service</span><br><span class="line">username = cinder</span><br><span class="line">password = 123</span><br><span class="line"></span><br><span class="line">在 [oslo_concurrency] 部分，配置锁路径：</span><br><span class="line">lock_path = /var/lib/cinder/tmp</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">配置完毕后wq退出并保存</span><br><span class="line"></span><br><span class="line">[root@controller ~]# su -s /bin/sh -c &quot;cinder-manage db sync&quot; cinder    #初始化块设备服务的数据库</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603190536831.png" alt="image-20230603190536831"></p>
<ul>
<li>修改nova配置文件</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">编辑文件 /etc/nova/nova.conf 并添加如下到其中：</span><br><span class="line"></span><br><span class="line">[root@controller ~]# vim /etc/nova/nova.conf</span><br><span class="line"></span><br><span class="line">在[cinder]下添加</span><br><span class="line">os_region_name = RegionOne</span><br></pre></td></tr></table></figure>

<ul>
<li>重启服务并设置开机自启</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">重启计算API 服务：</span><br><span class="line">[root@controller ~]# systemctl restart openstack-nova-api.service</span><br><span class="line"></span><br><span class="line">启动块设备存储服务，并将其配置为开机自启：</span><br><span class="line">[root@controller ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service</span><br><span class="line">[root@controller ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service</span><br></pre></td></tr></table></figure>

<ul>
<li>Compute节点安装并配置一个存储节点</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">[root@compute ~]# yum -y install lvm2 </span><br><span class="line"></span><br><span class="line">启动LVM的metadata服务并且设置该服务随系统启动：</span><br><span class="line">[root@controller ~]# systemctl start lvm2-lvmetad.service</span><br><span class="line">[root@controller ~]# systemctl enable lvm2-lvmetad.service</span><br><span class="line"></span><br><span class="line">先查看磁盘是否存在sdb</span><br><span class="line">lsblk</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603192822520.png" alt="image-20230603192822520"></p>
<ul>
<li>如果没有sdb就去虚拟机创建一个磁盘分区然后再reboot重启虚拟机，查看lsblk磁盘。<img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603194257554.png" alt="image-20230603194257554" style="zoom: 50%;" /></li>
</ul>
<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603194502727.png" alt="image-20230603194502727"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">创建LVM 物理卷分区 /dev/sdb：  </span><br><span class="line">[root@compute ~]# fdisk /dev/sdb</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603194925270.png" alt="image-20230603194925270"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"># pvcreate /dev/sdb1  #创建LVM物理卷</span><br></pre></td></tr></table></figure>

<ul>
<li>创建 LVM 卷组 cinder-volumes</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vgcreate cinder-volumes /dev/sdb1 </span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603195207730.png" alt="image-20230603195207730"></p>
<ul>
<li>编辑&#x2F;etc&#x2F;lvm&#x2F;lvm.conf文件,并修改</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># lsblk</span><br><span class="line"></span><br><span class="line"># vi /etc/lvm/lvm.conf</span><br><span class="line">在``devices``部分，添加一个过滤器，接受使用lvm的设备：</span><br><span class="line"></span><br><span class="line">filter = [ &quot;a/sdb/&quot;, &quot;r/.*/&quot;]</span><br></pre></td></tr></table></figure>

<ul>
<li>安装并配置组件(Compute节点)</li>
</ul>
<p>安装软件包</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install openstack-cinder targetcli python-keystone</span><br></pre></td></tr></table></figure>

<p>编辑相关配置文件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/cinder/cinder.conf</span><br><span class="line"></span><br><span class="line">cp /etc/cinder/cinder.conf&#123;,.bak&#125;    </span><br><span class="line">egrep -v &#x27;^$|#&#x27; /etc/cinder/cinder.conf.bak  &gt; /etc/cinder/cinder.conf</span><br><span class="line"></span><br><span class="line">在[DEFAULT]下添加</span><br><span class="line">rpc_backend = rabbit</span><br><span class="line">auth_strategy = keystone</span><br><span class="line">my_ip = 192.168.230.111                         #这里的IP地址是计算节点的ip</span><br><span class="line">enabled_backends = lvm</span><br><span class="line">glance_api_servers = http://controller:9292</span><br><span class="line"></span><br><span class="line">在[database]下添加</span><br><span class="line">connection = mysql+pymysql://cinder:123@controller/cinder</span><br><span class="line"></span><br><span class="line">在[oslo_messaging_rabbit]”部分，配置 “RabbitMQ” 消息队列访问：</span><br><span class="line">rabbit_host = controller</span><br><span class="line">rabbit_userid = openstack</span><br><span class="line">rabbit_password = 123</span><br><span class="line"></span><br><span class="line">在[keystone_authtoken]” 部分，配置认证服务访问：</span><br><span class="line">auth_uri = http://controller:5000</span><br><span class="line">auth_url = http://controller:35357</span><br><span class="line">memcached_servers = controller:11211</span><br><span class="line">auth_type = password</span><br><span class="line">project_domain_name = default</span><br><span class="line">user_domain_name = default</span><br><span class="line">project_name = service</span><br><span class="line">username = cinder</span><br><span class="line">password = 123</span><br><span class="line"></span><br><span class="line">添加[lvm]项</span><br><span class="line">[lvm]</span><br><span class="line">volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver</span><br><span class="line">volume_group = cinder-volumes</span><br><span class="line">iscsi_protocol = iscsi</span><br><span class="line">iscsi_helper = lioadm</span><br><span class="line"></span><br><span class="line">在 [oslo_concurrency] 部分，配置锁路径：</span><br><span class="line">lock_path = /var/lib/cinder/tmp</span><br></pre></td></tr></table></figure>

<ul>
<li>启动块存储卷服务及其依赖的服务，并将其配置为随系统启动</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># systemctl start openstack-cinder-volume.service target.service</span><br><span class="line"># systemctl enable openstack-cinder-volume.service target.service</span><br></pre></td></tr></table></figure>

<ul>
<li>控制节点验证</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cinder service-list  #列出cinder进程</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603200517260.png" alt="image-20230603200517260"></p>
<ul>
<li>控制节点创建卷</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">创建卷</span><br><span class="line"># cinder create --display-name v1 1</span><br><span class="line"># cinder list</span><br></pre></td></tr></table></figure>

<p><img src="C:\Users\23915\AppData\Roaming\Typora\typora-user-images\image-20230603200615336.png" alt="image-20230603200615336"></p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

   
   
  
</article>

    
  </article>
  

  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2015-2025
        <i class="ri-heart-fill heart_icon"></i> John Doe
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="妮子和平子"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E6%97%85%E8%A1%8C/%E7%94%9F%E6%B4%BB/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="http://shenyu-vip.lofter.com">摄影</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2025/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/default-skin/default-skin.min.css">
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->
 
<script src="/js/dz.js"></script>
 
<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>